<?php
if(!defined('RSMSINC'))
{
	exit("Request Error!");
}
function lib_slidebanner(&$ctag,&$refObj)
{
	global $dsql,$envs,$cfg_basedir,$cfg_basehost;
	
	//属性处理
	$attlist="row|12,titlelen|24";
	FillAttsDefault($ctag->CAttribute->Items,$attlist);
	extract($ctag->CAttribute->Items, EXTR_SKIP);
	$revalue = '';
	$path = $cfg_basedir."/uploads/slidebanner/";
	$rpath = $cfg_basehost."/uploads/slidebanner/";
	//你需编写的代码，不能用echo之类语法，把最终返回值传给$revalue
	//------------------------------------------------------
	$dh = dir($path);
	$files = array();
	while(($file = $dh->read()) !== false)
	{
		if($file == "." || $file == ".." || is_dir("$path/$file"))
		{
			continue;
		}
		
		$files[] = $rpath.$file;
	}
	
	if (empty($files))
		return "No picture under '/uploads/slidebanner/' directory!";
	
	$links = array();
	$dsql->SetQuery ("Select id,link,description From `#@__hotlink` order by id asc");
	$dsql->Execute();
	
	while($row = $dsql->GetObject())
	{
		 $links[] = $row->link;
	}
	
	$revalue = "<SCRIPT language=javascript>var m_nPageInitTime = new Date();
			var MainTopRoll = new RollingImageTrans('IMG_MAIN_TOP_ROLL_DETAIL', 		
			'IMGS_MAIN_TOP_ROLL_THUMBNAIL');";
			
	foreach ($files as $key=>$file)
	{
		$revalue .= "MainTopRoll.addItem
			('$links[$key]','$file');";
	}
			
	$revalue .= "</SCRIPT>";

	$revalue .= "<DIV id=SlideMain><IMG class=SlideMainRoll src='$files[0]' width=708 height=247 border=0 name=IMG_MAIN_TOP_ROLL_DETAIL> </DIV>";
	
	$revalue .= "<DIV id=SlideMenu><UL>";
	
	foreach ($files as $key => $file)
	{
		$revalue .= "<LI class=SlideMenuOut id=$key-l 
  onmouseover=\"document.getElementById('$key-l').className='SlideMenuOver'\"
  onmouseout=\"document.getElementById('$key-l').className='SlideMenuOut'\"><IMG 
  style='DISPLAY: none' height=5 
  src='$links[$key]'
  width=9 align=absMiddle border=0 name=IMGS_MAIN_TOP_ROLL_THUMBNAIL> <IMG 
  onmouseover=MainTopRoll.alterImage($key) style='CURSOR: pointer' height=50 
  src='$file' width=50 border=0> </LI>\n";
	}
  
  	$revalue .= "</UL></DIV>";
	
	$revalue .= "<SCRIPT language=JavaScript>
					MainTopRoll.Index =  parseInt('0');
					MainTopRoll.install();	</SCRIPT>";
	
	//------------------------------------------------------
	return $revalue;
}
?>